extends Node2D

export(Array, PackedScene) var enemies

func _ready():
	Global.node_creation_parent = self
	Global.points = 0

func _exit_tree():
	Global.node_creation_parent = null

func _on_Enemy_spawn_timer_timeout():
	var enemy_position = Vector2(rand_range(-80, 720), rand_range(-80, 420))
	
	while enemy_position.x<680 and enemy_position.x>-40 or enemy_position.y<380 and enemy_position.y>-40:
		enemy_position = Vector2(rand_range(-80, 720), rand_range(-80, 420))
	
	var enemy_number = round(rand_range(0, enemies.size() - 1))
	Global.instance_node(enemies[enemy_number], enemy_position, self)


func _on_DifficultTimer_timeout():
	if $Enemy_spawn_timer.wait_time > 0.5:
		$Enemy_spawn_timer.wait_time -= 0.025
